import java.util.Scanner;

public class Text2 {
    /*public static String func(String a,String b){
        char[] A = a.toCharArray();
        char[] B = b.toCharArray();
        int tmp1=0,tmp2=0;
        int a1=0;int a2=0;
        int ret=0;

        for (int i = 0;i<a.length();i++){
            for (int j=0;j<b.length();j++){
                a1=i;a2=j;
                while (A[i]==B[j]&&i<a.length()-1&&j<b.length()-1){
                    tmp2++;
                    i++;
                    j++;
                }
                i=a1;j=a2+1;
                if (tmp2>tmp1){
                    tmp1=tmp2;
                    ret=j;
                }
            }
        }

        int[] arr = new int[tmp1];
        for (int i=ret,j=0;i<ret+tmp1;i++){
            arr[j]=B[i];
            j++;
        }
        return arr.toString();
    }*/

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        char[] A = a.toCharArray();
        char[] B = b.toCharArray();
        int tmp1=0,tmp2=0;
        int a1=0;int a2=0;
        int ret=0;

        for (int i = 0;i<a.length();i++){
            for (int j=0;j<b.length();j++){
                a1=i;a2=j;
                while (A[i]==B[j]&&i<a.length()-1&&j<b.length()-1){
                    tmp2++;
                    i++;
                    j++;
                }
                i=a1;j=a2+1;
                if (tmp2>tmp1){
                    tmp1=tmp2;
                    ret=j;
                }
            }
        }

        int[] arr = new int[tmp1];
        for (int i=ret,j=0;i<ret+tmp1&&i< B.length;i++){
            arr[j]=B[i];
            j++;
        }

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
